home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / glib-2.0 / glib / garray.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-04-25  |  6.3 KB  |  168 lines

  1. /* GLIB - Library of useful routines for C programming
  2.  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
  3.  *
  4.  * This library is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU Lesser General Public
  6.  * License as published by the Free Software Foundation; either
  7.  * version 2 of the License, or (at your option) any later version.
  8.  *
  9.  * This library is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the GNU
  12.  * Lesser General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU Lesser General Public
  15.  * License along with this library; if not, write to the
  16.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.  * Boston, MA 02111-1307, USA.
  18.  */
  19.  
  20. /*
  21.  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
  22.  * file for a list of people on the GLib Team.  See the ChangeLog
  23.  * files for a list of changes.  These files are distributed with
  24.  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  25.  */
  26.  
  27. #ifndef __G_ARRAY_H__
  28. #define __G_ARRAY_H__
  29.  
  30. #include <glib/gtypes.h>
  31.  
  32. G_BEGIN_DECLS
  33.  
  34. typedef struct _GArray        GArray;
  35. typedef struct _GByteArray    GByteArray;
  36. typedef struct _GPtrArray    GPtrArray;
  37.  
  38. struct _GArray
  39. {
  40.   gchar *data;
  41.   guint len;
  42. };
  43.  
  44. struct _GByteArray
  45. {
  46.   guint8 *data;
  47.   guint      len;
  48. };
  49.  
  50. struct _GPtrArray
  51. {
  52.   gpointer *pdata;
  53.   guint        len;
  54. };
  55.  
  56. /* Resizable arrays. remove fills any cleared spot and shortens the
  57.  * array, while preserving the order. remove_fast will distort the
  58.  * order by moving the last element to the position of the removed.
  59.  */
  60.  
  61. #define g_array_append_val(a,v)      g_array_append_vals (a, &(v), 1)
  62. #define g_array_prepend_val(a,v)  g_array_prepend_vals (a, &(v), 1)
  63. #define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &(v), 1)
  64. #define g_array_index(a,t,i)      (((t*) (a)->data) [(i)])
  65.  
  66. GArray* g_array_new               (gboolean          zero_terminated,
  67.                    gboolean          clear_,
  68.                    guint             element_size);
  69. GArray* g_array_sized_new         (gboolean          zero_terminated,
  70.                    gboolean          clear_,
  71.                    guint             element_size,
  72.                    guint             reserved_size);
  73. gchar*  g_array_free              (GArray           *array,
  74.                    gboolean          free_segment);
  75. GArray* g_array_append_vals       (GArray           *array,
  76.                    gconstpointer     data,
  77.                    guint             len);
  78. GArray* g_array_prepend_vals      (GArray           *array,
  79.                    gconstpointer     data,
  80.                    guint             len);
  81. GArray* g_array_insert_vals       (GArray           *array,
  82.                    guint             index_,
  83.                    gconstpointer     data,
  84.                    guint             len);
  85. GArray* g_array_set_size          (GArray           *array,
  86.                    guint             length);
  87. GArray* g_array_remove_index      (GArray           *array,
  88.                    guint             index_);
  89. GArray* g_array_remove_index_fast (GArray           *array,
  90.                    guint             index_);
  91. GArray* g_array_remove_range      (GArray           *array,
  92.                    guint             index_,
  93.                    guint             length);
  94. void    g_array_sort              (GArray           *array,
  95.                    GCompareFunc      compare_func);
  96. void    g_array_sort_with_data    (GArray           *array,
  97.                    GCompareDataFunc  compare_func,
  98.                    gpointer          user_data);
  99.  
  100. /* Resizable pointer array.  This interface is much less complicated
  101.  * than the above.  Add appends a pointer.  Remove fills any cleared 
  102.  * spot and shortens the array. remove_fast will again distort order.  
  103.  */
  104. #define    g_ptr_array_index(array,index_) ((array)->pdata)[index_]
  105. GPtrArray* g_ptr_array_new                (void);
  106. GPtrArray* g_ptr_array_sized_new          (guint             reserved_size);
  107. gpointer*  g_ptr_array_free               (GPtrArray        *array,
  108.                        gboolean          free_seg);
  109. void       g_ptr_array_set_size           (GPtrArray        *array,
  110.                        gint              length);
  111. gpointer   g_ptr_array_remove_index       (GPtrArray        *array,
  112.                        guint             index_);
  113. gpointer   g_ptr_array_remove_index_fast  (GPtrArray        *array,
  114.                        guint             index_);
  115. gboolean   g_ptr_array_remove             (GPtrArray        *array,
  116.                        gpointer          data);
  117. gboolean   g_ptr_array_remove_fast        (GPtrArray        *array,
  118.                        gpointer          data);
  119. void       g_ptr_array_remove_range       (GPtrArray        *array,
  120.                        guint             index_,
  121.                        guint             length);
  122. void       g_ptr_array_add                (GPtrArray        *array,
  123.                        gpointer          data);
  124. void       g_ptr_array_sort               (GPtrArray        *array,
  125.                        GCompareFunc      compare_func);
  126. void       g_ptr_array_sort_with_data     (GPtrArray        *array,
  127.                        GCompareDataFunc  compare_func,
  128.                        gpointer          user_data);
  129. void       g_ptr_array_foreach            (GPtrArray        *array,
  130.                        GFunc             func,
  131.                        gpointer          user_data);
  132.  
  133.  
  134. /* Byte arrays, an array of guint8.  Implemented as a GArray,
  135.  * but type-safe.
  136.  */
  137.  
  138. GByteArray* g_byte_array_new               (void);
  139. GByteArray* g_byte_array_sized_new         (guint             reserved_size);
  140. guint8*     g_byte_array_free              (GByteArray       *array,
  141.                         gboolean          free_segment);
  142. GByteArray* g_byte_array_append            (GByteArray       *array,
  143.                         const guint8     *data,
  144.                         guint             len);
  145. GByteArray* g_byte_array_prepend           (GByteArray       *array,
  146.                         const guint8     *data,
  147.                         guint             len);
  148. GByteArray* g_byte_array_set_size          (GByteArray       *array,
  149.                         guint             length);
  150. GByteArray* g_byte_array_remove_index      (GByteArray       *array,
  151.                         guint             index_);
  152. GByteArray* g_byte_array_remove_index_fast (GByteArray       *array,
  153.                         guint             index_);
  154. GByteArray* g_byte_array_remove_range      (GByteArray       *array,
  155.                         guint             index_,
  156.                         guint             length);
  157. void        g_byte_array_sort              (GByteArray       *array,
  158.                         GCompareFunc      compare_func);
  159. void        g_byte_array_sort_with_data    (GByteArray       *array,
  160.                         GCompareDataFunc  compare_func,
  161.                         gpointer          user_data);
  162.  
  163.  
  164. G_END_DECLS
  165.  
  166. #endif /* __G_ARRAY_H__ */
  167.  
  168.